using System.Collections.Generic;

namespace Intyme.Common.DataModel {
    /// <summary>
    /// Class define data and structure for One Component 
    /// </summary>  
    public class ComponentClass {
        public int ID = -2;
        public string Name;
        public Dictionary<int, OperationClass> Operations;
        public Dictionary<int, ComponentClass> ChildComponents;

        public ComponentClass() {
            ID = -1;
            Name = string.Empty;
            if (Operations == null) {
                Operations = new Dictionary<int, OperationClass>();
            }

            if (ChildComponents == null) {
                ChildComponents = new Dictionary<int, ComponentClass>();
            }
        }

        ~ComponentClass() {
            if (Operations != null) {
                Operations.Clear();
                Operations = null;
            }

            if (ChildComponents != null) {
                ChildComponents.Clear();
                ChildComponents = null;
            }
        }

        public bool IsComponentCorrect() {
            if (
                (ID >= 0) &&
                (Name != null && Name != string.Empty) &&
                (Operations != null && Operations.Count > 0)
                ) {
                return true;
            }

            return false;
        }
    }
}